import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store= new Vuex.Store({
    state:{
        gId:1,
        apilist:[
        ]
    },
    mutations:{
        incId:(state)=>{
            state.gId++
        },
        add:(state,n)=>{
            for (const v of state.apilist) {
                if (v.id==n.id) {
                    return
                }
            }
            state.apilist.push(n)
        },
        update:(state,n)=>{
            for (const v of state.apilist) {
                if (v.id==n.id) {
                    state.apilist[state.apilist.indexOf(v)]=n
                    return
                }
            }
        },
        remove:(state,n)=>{
            for (const v of state.apilist) {
                if (v.id===n.id) {
                    state.apilist.splice(state.apilist.indexOf(v),1)
                }
            }
        },

    }
})

import index from './index.vue'
import router from './router.js';

new Vue({
    router,
    store,
    render: h => h(index)
}).$mount('#app');
